<?php

/*
 * Edit by xinli
 * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
 */
namespace api\admin\controller;

use cmf\controller\RestAdminBaseController;
use api\mall\model\IMSessionModel;
use app\user\model\UserModel;

/**
 * Description of IMSessionController
 *
 * @author PC
 */
class IMSessionController extends RestAdminBaseController
{
    //put your code here
    public function index()
    {

    }

    public function status($id, $status)
    {
        $sessionModel = new IMSessionModel();
        $session = $sessionModel->where('id', $id)->find();
        if (empty($session)) {
            $this->error("会话不存在");
        }

        $update = [];
        $update['chat_change_time'] = time();
        $userModel = new UserModel();
        $userModel->where('id', $session['send_user_id'])->update($update);

        $sessionModel->where('id', $id)->update(['session_status' => $status, 'update_time' => time()]);
        $this->success("修改成功");
    }
}
